package com.zqxq.lottery.api.controller;

import com.zqxq.common.constant.Result;
import com.zqxq.common.enums.CodeEnum;
import com.zqxq.common.utils.StrUtils;
import com.zqxq.lottery.api.feign.LotteryServerFeignClient;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author
 * @date 2018/8/3 17:28
 * @description 跟单功能
 * @ClassName FollowOrderController
 */
@Api(value = "跟单功能接口",tags = "跟单功能接口")
@RestController
@RequestMapping("/follow")
@Slf4j
public class FollowOrderController {
    @Autowired
    private LotteryServerFeignClient lotteryServerFeignClient;

    @PostMapping("/orderList")
    @ApiOperation("跟单列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型 1:人气2：命中3：盈利4：关注", required = true, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "pageNo", value = "页码", required = true, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "pageSize", value = "每页条数", required = true, paramType = "query", dataType = "Integer"),
            @ApiImplicitParam(name = "followUserId", value = "跟单用户id", required = false,paramType = "query",dataType = "String")
    })
    public Result getFollowOrder(Integer type,Integer pageNo, Integer pageSize,String followUserId){
        log.info("获取跟单列表type={}",type);
        Result result = lotteryServerFeignClient.getFollowOrder(type,pageNo,pageSize,followUserId);
        return result;
    }

    @PostMapping("/programmeDetail")
    @ApiOperation("方案详情")
    public Result getProgrammeDetail(@ApiParam(value = "订单id",required = true) @RequestParam("orderId") String orderId,
                                     @ApiParam(value = "专家id",required = true) @RequestParam("expertId")String expertId,
                                     @ApiParam(value = "跟单用户id",required = true) @RequestParam("followUserId")String followUserId){
        log.info("方案详情orderId={}",orderId);
        Result result = lotteryServerFeignClient.getProgrammeDetail(orderId,expertId,followUserId);
        return result;
    }

    @PostMapping("/expertDetail")
    @ApiOperation("专家详情")
    public Result getExpertDetail(@ApiParam(value = "专家id",required = true) @RequestParam("userId") String userId,
                                  @ApiParam(value = "跟单用户id",required = true) @RequestParam("followUserId") String followUserId){
        log.info("专家详情userId={}",userId);
        Result result = lotteryServerFeignClient.getExpertDetail(userId,followUserId);
        return result;
    }

    @ApiOperation("推单列表")
    @PostMapping("/pushOrderList")
    public Result getPushOrderList(@ApiParam(value = "专家id",required = true) @RequestParam("userId") String userId,
                                   @ApiParam(value = "type：1：近7日2：近30日",required = true) @RequestParam(defaultValue = "1") Integer type,
                                   @ApiParam(value = "status：1：中奖推单2：待开推单3：未中推单",required = true)@RequestParam(defaultValue = "1") Integer status,
                                   @ApiParam(value = "页码",required = true) @RequestParam(defaultValue = "1") Integer pageNo,
                                   @ApiParam(value = "每页条数",required = true) @RequestParam(defaultValue = "10") Integer pageSize){
        log.info("推单列表userId={},type={},status={}",userId,type,status);
        Result result = lotteryServerFeignClient.getPushOrderList(userId, type, status,pageNo,pageSize);
        return result;
    }

}
